// Copyright 2022 a.o.smith ALL Rights Reserved
package com.liuxinlong.modules.standard.controller;

import com.liuxinlong.common.TreeNode;
import com.liuxinlong.modules.common.controller.request.QueryBaseReq;
import com.liuxinlong.modules.common.controller.response.BaseResp;
import com.liuxinlong.modules.standard.service.StandardMapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 标准控制层
 *
 * @author liuxinlong@hotwater.com.cn
 * @version 1.0.0
 * @since 2022年1月21日
 */
@RestController
@RequestMapping("/standard-map")
public class StandardMapController {

    @Autowired
    private StandardMapService standardMapService;

    /**
     * 查询知识图谱
     *
     * @return 知识图谱信息
     */
    @PostMapping("query")
    public BaseResp queryKnowledgeGraph(@RequestBody QueryBaseReq req) {
        TreeNode resulTreeNode = standardMapService.queryKnowledgeGraph(req.getId());
        Map<String, Object> map = new HashMap<>();
        map.put("data", resulTreeNode);
        BaseResp resp = new BaseResp();
        resp.setDataMap(map);
        resp.setRetMessage("查询知识图谱成功");
        return resp;
    }

    /**
     * 查询知识图谱
     *
     * @return 知识图谱信息
     */
    @PostMapping("detail")
    public BaseResp queryMapDetail(@RequestBody QueryBaseReq req) {
        List<Map<String, Object>> resultList = standardMapService.queryMapDetail(req.getId(),req.getStartNum());
        BaseResp resp = new BaseResp();
        resp.setDataList(resultList);
        resp.setRetMessage("查询知识图谱成功");
        return resp;
    }
}
